$(function () {
    // ********************************添加用户
    var layer = layui.layer
    var form = layui.form
    form.verify({
        password: function (value, item) {
            let pwd1 = $('.pwd1').val()
            if (value !== pwd1) {
                return '确认密码错误'
            }
        }
    });
    $('form').on('submit', function (e) {
        e.preventDefault()
        let data = form.val("user-add")
        $.ajax({
            type: 'POST',
            url: '/admin/users',
            data: data,
            success: function (res) {
                layer.msg(res.message)
                form.val('')
                setTimeout(function () {
                    location.href = '/user/user.html'
                }, 700)
            }
        })
    })
})